package com.fh.auth;

import org.jasig.cas.authentication.handler.AuthenticationException;
import org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler;
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials;

public class MyAuthenticationHandler extends AbstractUsernamePasswordAuthenticationHandler {

	@Override
	protected boolean authenticateUsernamePasswordInternal(UsernamePasswordCredentials credentials) throws AuthenticationException {
		MyCredentials myCredentials = (MyCredentials) credentials;
		final String username = myCredentials.getUsername();
		final String password = myCredentials.getPassword();
		//个性化参数
		String sysCode = myCredentials.getSysCode();
		System.out.println("登录参数sysCode=="+sysCode);
		if (username != null && password != null && !"".equals(username) && !"".equals(password)) {
			StringBuffer sb = new StringBuffer(username);
			if (sb.reverse().toString().equals(password)) {
				return true;
			}
		}
		return false;
	}

}
